package tpi.obj3.dsle.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import tpi.obj3.dsle.dSLE.Aula;
import tpi.obj3.dsle.dSLE.Clase;
import tpi.obj3.dsle.dSLE.DSLEPackage;
import tpi.obj3.dsle.dSLE.Dia;
import tpi.obj3.dsle.dSLE.Materia;
import tpi.obj3.dsle.dSLE.Modelo;
import tpi.obj3.dsle.dSLE.Planificacion;
import tpi.obj3.dsle.dSLE.Profesor;
import tpi.obj3.dsle.dSLE.Recurso;
import tpi.obj3.dsle.services.DSLEGrammarAccess;

@SuppressWarnings("all")
public class DSLESemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private DSLEGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == DSLEPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case DSLEPackage.AULA:
				if(context == grammarAccess.getAulaRule() ||
				   context == grammarAccess.getElementoRule()) {
					sequence_Aula(context, (Aula) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.CLASE:
				if(context == grammarAccess.getClaseRule()) {
					sequence_Clase(context, (Clase) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.DIA:
				if(context == grammarAccess.getDiaRule()) {
					sequence_Dia(context, (Dia) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.MATERIA:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getMateriaRule()) {
					sequence_Materia(context, (Materia) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.MODELO:
				if(context == grammarAccess.getModeloRule()) {
					sequence_Modelo(context, (Modelo) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.PLANIFICACION:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getPlanificacionRule()) {
					sequence_Planificacion(context, (Planificacion) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.PROFESOR:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getProfesorRule()) {
					sequence_Profesor(context, (Profesor) semanticObject); 
					return; 
				}
				else break;
			case DSLEPackage.RECURSO:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getRecursoRule()) {
					sequence_Recurso(context, (Recurso) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (name=ID recursos+=[Recurso|ID]*)
	 */
	protected void sequence_Aula(EObject context, Aula semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (inicio=INT fin=INT materia=[Materia|ID] aula=[Aula|ID])
	 */
	protected void sequence_Clase(EObject context, Clase semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.CLASE__INICIO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.CLASE__INICIO));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.CLASE__FIN) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.CLASE__FIN));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.CLASE__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.CLASE__MATERIA));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.CLASE__AULA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.CLASE__AULA));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getClaseAccess().getInicioINTTerminalRuleCall_1_0(), semanticObject.getInicio());
		feeder.accept(grammarAccess.getClaseAccess().getFinINTTerminalRuleCall_3_0(), semanticObject.getFin());
		feeder.accept(grammarAccess.getClaseAccess().getMateriaMateriaIDTerminalRuleCall_5_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getClaseAccess().getAulaAulaIDTerminalRuleCall_7_0_1(), semanticObject.getAula());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     clase+=Clase*
	 */
	protected void sequence_Dia(EObject context, Dia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID nombre=STRING horasSemanales=INT diasSemanales=INT recursos+=[Recurso|ID]*)
	 */
	protected void sequence_Materia(EObject context, Materia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     elementos+=Elemento*
	 */
	protected void sequence_Modelo(EObject context, Modelo semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         anio=INT 
	 *         semestre=INT 
	 *         lunes=Dia 
	 *         martes=Dia 
	 *         miercoles=Dia 
	 *         jueves=Dia 
	 *         viernes=Dia 
	 *         sabado=Dia
	 *     )
	 */
	protected void sequence_Planificacion(EObject context, Planificacion semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__ANIO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__ANIO));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__SEMESTRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__SEMESTRE));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__LUNES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__LUNES));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__MARTES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__MARTES));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__MIERCOLES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__MIERCOLES));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__JUEVES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__JUEVES));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__VIERNES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__VIERNES));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PLANIFICACION__SABADO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PLANIFICACION__SABADO));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPlanificacionAccess().getAnioINTTerminalRuleCall_1_0(), semanticObject.getAnio());
		feeder.accept(grammarAccess.getPlanificacionAccess().getSemestreINTTerminalRuleCall_3_0(), semanticObject.getSemestre());
		feeder.accept(grammarAccess.getPlanificacionAccess().getLunesDiaParserRuleCall_6_0(), semanticObject.getLunes());
		feeder.accept(grammarAccess.getPlanificacionAccess().getMartesDiaParserRuleCall_8_0(), semanticObject.getMartes());
		feeder.accept(grammarAccess.getPlanificacionAccess().getMiercolesDiaParserRuleCall_10_0(), semanticObject.getMiercoles());
		feeder.accept(grammarAccess.getPlanificacionAccess().getJuevesDiaParserRuleCall_12_0(), semanticObject.getJueves());
		feeder.accept(grammarAccess.getPlanificacionAccess().getViernesDiaParserRuleCall_14_0(), semanticObject.getViernes());
		feeder.accept(grammarAccess.getPlanificacionAccess().getSabadoDiaParserRuleCall_16_0(), semanticObject.getSabado());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID nombre=STRING dedicacion=Dedicacion)
	 */
	protected void sequence_Profesor(EObject context, Profesor semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PROFESOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PROFESOR__NAME));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PROFESOR__NOMBRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PROFESOR__NOMBRE));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.PROFESOR__DEDICACION) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.PROFESOR__DEDICACION));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getProfesorAccess().getNameIDTerminalRuleCall_0_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getProfesorAccess().getNombreSTRINGTerminalRuleCall_2_0(), semanticObject.getNombre());
		feeder.accept(grammarAccess.getProfesorAccess().getDedicacionDedicacionParserRuleCall_4_0(), semanticObject.getDedicacion());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID nombre=STRING)
	 */
	protected void sequence_Recurso(EObject context, Recurso semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.RECURSO__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.RECURSO__NAME));
			if(transientValues.isValueTransient(semanticObject, DSLEPackage.Literals.RECURSO__NOMBRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DSLEPackage.Literals.RECURSO__NOMBRE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getRecursoAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getRecursoAccess().getNombreSTRINGTerminalRuleCall_3_0(), semanticObject.getNombre());
		feeder.finish();
	}
}
